package com.guestbook;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.util.logging.Logger;

public class GuestbookServlet extends HttpServlet {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final Logger log = Logger.getLogger(GuestbookServlet.class.getName());
	
	@Override
	protected void doGet(HttpServletRequest req,
			HttpServletResponse resp) throws ServletException, IOException {
		resp.sendRedirect("/guestbook.jsp");
	}
	
    public void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws IOException {
    	PrintWriter out = resp.getWriter();
        String content = req.getParameter("content");
        log.info("Greeting posted: " + content);
        resp.sendRedirect("/guestbook.jsp?username="+content);
    }
}